package com.albert.thread;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import static com.albert.thread.ThreadPool.service;

public class AllAnyOf {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> img0 = CompletableFuture.supplyAsync(() -> {
            System.out.println("查村基本信息");
            return "helloJPG";
        }, service);
        CompletableFuture<String> attr = CompletableFuture.supplyAsync(() -> {
            try {
                Thread.sleep(3000);
                System.out.println("查村属性信息");

            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            return "hello256G";
        }, service);
        CompletableFuture<String> introduce = CompletableFuture.supplyAsync(() -> {
            System.out.println("查询商品介绍");
            return "华为";
        }, service);

        //CompletableFuture<Void> future = CompletableFuture.allOf(img0, attr, introduce);
        CompletableFuture<Object> future = CompletableFuture.anyOf(img0, attr, introduce);
        future.get();


        System.out.println("全部完成");
    }
}
